<template>
	<div class="box"></div>
</template>
<script>
export default {
	data() {
		return {
			str: `
			abcccdb
			bcdccd
			efgccd
			`,
			str1: `abcccdd\nbcdccd\nefgccd`,
			str2: 'ddabcXabcd',
			str3: 'ddabcxXxabcd',
			str4: `
				abc
				gbd
			`,
			str5: `1abc cbc`
		}
	},
	methods: {
		test() {
			console.log(this.str);
			let ms = this.str.match(/^\s*bcd/m);
			console.log(ms);

			let r1 = /(abc)X\1/;
			ms = this.str2.match(r1);
			console.log(ms);

			r1 = /(?:abc)(x)X\1/;
			ms = this.str3.match(r1);
			console.log(ms);
			//. 的匹配行结尾
			r1 = /abc.*gbd/s
			ms = this.str4.match(r1);
			//\b的是不包含字母 \B包含字母 单词边界判断\b为单词边界 \B为非单词边界
			r1 = /\babc\b/
			ms = this.str5.match(r1);
			//\w [A-Z,a-z,0-9,_]
			console.log(ms);

			r1 = /(?=(a+))a*b\1/
			let str = 'baabac'; //逐个字符匹配
			ms = str.match(r1);
			console.log(ms);

			console.log(`m的模式`)
			str = `abc
abcd
abc`
			r1 = /^abc/gm;
			ms = str.match(r1);
			console.log(ms);
			console.log(`回文`)
			r1 = /((.+)(.+)(.+)\3\2\1)/;
			str = 'abcabccbadddd';
			let flag = r1.test(str);
			let res = str.match(r1)
			console.log(`flag`, flag, res);
		}
	},
	mounted() {
		this.test();
	}
}
</script>
<style lang="scss" scoped>
.box {
	width: 100px;
	height: 100px;
	border: 1px solid #000;
}
</style>